
IF(WIN32)
	ADD_DEFINITIONS(-D__WXMSW__)
ENDIF(WIN32)

# omit buffer security checkes, increases hashing speed, only available with >= MSVC2005
IF(MSVC80 OR MSVC90 OR MSVC10)
	ADD_DEFINITIONS(/GS-)
ENDIF(MSVC80 OR MSVC90 OR MSVC10)

IF(BITCOIN_4WAYSSE2)
	ADD_DEFINITIONS(-DFOURWAYSSE2)
	IF(MSVC)
		ADD_DEFINITIONS(/arch:SSE2)
	ENDIF(MSVC)
ENDIF(BITCOIN_4WAYSSE2)

FIND_PACKAGE(CURL)

IF(CURL_FOUND)
	INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
ENDIF(CURL_FOUND)

SET(BITCOIN_RPC_MINER_SRC
	${CMAKE_SOURCE_DIR}/src/sha256.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/hex.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/httprequest.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcminerclient.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcminermain.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcminerthreadcpu.cpp
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcrequest.cpp
	${CMAKE_SOURCE_DIR}/src/json/json_spirit_reader.cpp
	${CMAKE_SOURCE_DIR}/src/json/json_spirit_value.cpp
	${CMAKE_SOURCE_DIR}/src/json/json_spirit_writer.cpp
	${CMAKE_SOURCE_DIR}/src/minercommon/base64.c
	${CMAKE_SOURCE_DIR}/src/cryptopp/cpu.cpp
	${CMAKE_SOURCE_DIR}/src/cryptopp/sha.cpp
)

SET(BITCOIN_RPC_MINER_CUDA_SRC
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcminerthreadgpu.cpp
	${CMAKE_SOURCE_DIR}/src/cuda/bitcoinminercuda.cpp
	${CMAKE_SOURCE_DIR}/src/cuda/bitcoinminercuda.cu
)

SET(BITCOIN_RPC_MINER_OPENCL_SRC
	${CMAKE_SOURCE_DIR}/src/rpcminer/rpcminerthreadgpu.cpp
	${CMAKE_SOURCE_DIR}/src/opencl/bitcoinmineropencl.cpp
)

IF(BITCOIN_ENABLE_CUDA)
	ADD_DEFINITIONS(-D_BITCOIN_MINER_CUDA_)
	CUDA_ADD_EXECUTABLE(rpcminer WIN32 ${BITCOIN_RPC_MINER_SRC} ${BITCOIN_RPC_MINER_CUDA_SRC})
ELSE(BITCOIN_ENABLE_CUDA)
	IF(BITCOIN_ENABLE_OPENCL)
		ADD_DEFINITIONS(-D_BITCOIN_MINER_OPENCL_)
		ADD_EXECUTABLE(rpcminer ${BITCOIN_RPC_MINER_SRC} ${BITCOIN_RPC_MINER_OPENCL_SRC})
	ELSE(BITCOIN_ENABLE_OPENCL)
		ADD_EXECUTABLE(rpcminer ${BITCOIN_RPC_MINER_SRC})
	ENDIF(BITCOIN_ENABLE_OPENCL)
ENDIF(BITCOIN_ENABLE_CUDA)

TARGET_LINK_LIBRARIES(rpcminer ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES})
IF(WIN32)
	TARGET_LINK_LIBRARIES(rpcminer winmm.lib shlwapi.lib)
ELSE(WIN32)
	TARGET_LINK_LIBRARIES(rpcminer pthread)
ENDIF(WIN32)

IF(BITCOIN_ENABLE_CUDA)
	TARGET_LINK_LIBRARIES(rpcminer ${CUDA_LIBRARIES})
ENDIF(BITCOIN_ENABLE_CUDA)

IF(BITCOIN_ENABLE_OPENCL)
	TARGET_LINK_LIBRARIES(rpcminer ${OPENCL_LIBRARY})
ENDIF(BITCOIN_ENABLE_OPENCL)